package com.woniuxy.hotel.room.mapper;

import com.woniuxy.hotel.room.pojo.Evaluate;
import com.woniuxy.hotel.room.pojo.EvaluateExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface EvaluateMapper {
    /**
     * 条件统计
     */
    @SelectProvider(type = EvaluateSqlProvider.class, method = "countByExample")
    int countByExample(EvaluateExample example);
    
    /**
     * 条件删除
     *
     * @param example 条件对象
     * @return
     */
    @DeleteProvider(type = EvaluateSqlProvider.class, method = "deleteByExample")
    int deleteByExample(EvaluateExample example);
    
    /**
     * 依主键删除
     *
     * @param evaluateid 主键
     * @return
     */
    @Delete({
            "delete from evaluate",
            "where evaluateId = #{evaluateid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer evaluateid);
    
    /**
     * 全属性插入
     *
     * @param record Evaluate对象，必须全属性拥有
     * @return
     */
    @Insert({
            "insert into evaluate (evaluateId, roomId, ",
            "hotelId, star, info)",
            "values (#{evaluateid,jdbcType=INTEGER}, #{roomid,jdbcType=INTEGER}, ",
            "#{hotelid,jdbcType=INTEGER}, #{star,jdbcType=INTEGER}, #{info,jdbcType=LONGVARCHAR})"
    })
    int insert(Evaluate record);
    
    /**
     * 动态插入，依据参数内容有无条件插入
     *
     * @param record Evaluate对象
     * @return 查询到的对象集合
     */
    @InsertProvider(type = EvaluateSqlProvider.class, method = "insertSelective")
    int insertSelective(Evaluate record);
    
    /**
     * 条件查询全部内容
     *
     * @param example 条件类对象
     * @return 符合条件的对象集合
     */
    @SelectProvider(type = EvaluateSqlProvider.class, method = "selectByExampleWithBLOBs")
    @Results({
            @Result(column = "evaluateId", property = "evaluateid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "star", property = "star", jdbcType = JdbcType.INTEGER),
            @Result(column = "info", property = "info", jdbcType = JdbcType.LONGVARCHAR)
    })
    List<Evaluate> selectByExampleWithBLOBs(EvaluateExample example);
    
    /**
     * 条件查询 除评价内容的
     *
     * @param example 条件类对象
     * @return 符合条件的对象集合
     */
    @SelectProvider(type = EvaluateSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "evaluateId", property = "evaluateid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "star", property = "star", jdbcType = JdbcType.INTEGER)
    })
    List<Evaluate> selectByExample(EvaluateExample example);
    
    /**
     * 主键查询
     * @param evaluateid 主键
     * @return
     */
    @Select({
            "select",
            "evaluateId, roomId, hotelId, star, info",
            "from evaluate",
            "where evaluateId = #{evaluateid,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "evaluateId", property = "evaluateid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "star", property = "star", jdbcType = JdbcType.INTEGER),
            @Result(column = "info", property = "info", jdbcType = JdbcType.LONGVARCHAR)
    })
    Evaluate selectByPrimaryKey(Integer evaluateid);
    
    /**
     * 依酒店id查询
     * @param hotelId 酒店id
     * @return
     */
    @Select({
            "select",
            "evaluateId, roomId, hotelId, star, info",
            "from evaluate",
            "where hotelId = #{hotelId,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "evaluateId", property = "evaluateid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "star", property = "star", jdbcType = JdbcType.INTEGER),
            @Result(column = "info", property = "info", jdbcType = JdbcType.LONGVARCHAR)
    })
    List<Evaluate> selectByHotelId(Integer hotelId);
    
    /**
     * 依房间id查询
     * @param roomId 房间id
     * @return
     */
    @Select({
            "select",
            "evaluateId, roomId, hotelId, star, info",
            "from evaluate",
            "where roomId = #{roomId,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "evaluateId", property = "evaluateid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "star", property = "star", jdbcType = JdbcType.INTEGER),
            @Result(column = "info", property = "info", jdbcType = JdbcType.LONGVARCHAR)
    })
    List<Evaluate> selectByRoomId(Integer roomId);
    
    /**
     * 不包含评价内容依属性选择更新
     *
     * @param record  新的实体类
     * @param example 条件类
     * @return
     */
    @UpdateProvider(type = EvaluateSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Evaluate record, @Param("example") EvaluateExample example);
    
    /**
     * 全内容依属性选择更新
     *
     * @param record  新的实体类
     * @param example 条件类
     * @return
     */
    @UpdateProvider(type = EvaluateSqlProvider.class, method = "updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Evaluate record, @Param("example") EvaluateExample example);
    
    @UpdateProvider(type = EvaluateSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") Evaluate record, @Param("example") EvaluateExample example);
    
    /**
     * 依据主键更新全部内容
     *
     * @param record 实体类
     * @return
     */
    @UpdateProvider(type = EvaluateSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Evaluate record);
    
    @Update({
            "update evaluate",
            "set roomId = #{roomid,jdbcType=INTEGER},",
            "hotelId = #{hotelid,jdbcType=INTEGER},",
            "star = #{star,jdbcType=INTEGER},",
            "info = #{info,jdbcType=LONGVARCHAR}",
            "where evaluateId = #{evaluateid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Evaluate record);
    
    /**
     * 依据主键更新不包含评价内容
     * @param record 实体类
     * @return
     */
    @Update({
            "update evaluate",
            "set roomId = #{roomid,jdbcType=INTEGER},",
            "hotelId = #{hotelid,jdbcType=INTEGER},",
            "star = #{star,jdbcType=INTEGER}",
            "where evaluateId = #{evaluateid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Evaluate record);
}